<?php

class RememberPeer extends BaseRememberPeer
{
	
    public $id;
    public $level;
    public $result;
    public $table;

    public function __construct()
    {
        $this->id     = 0;
        $this->level  = 0;
        $this->result = array();
        $this->table  = "";
    }
		
   public static function RememberOpenFolder($folder_id)
	{
		//echo print_r($folder_id);
		//die;
		$folder = FolderPeer::retrieveByPK($folder_id);
	  	///Запоминаем открытие
	  	$c = new Criteria();
	  	$c->add(RememberPeer::CLASS_NAME,'Folder');
	  	$c->addAnd(RememberPeer::ITEM_ID,$folder->getId());
	  	$c->addAnd(RememberPeer::SESSION_ID,session_id());
	  	
	  	$cnt = RememberPeer::doCount($c);
	  	if($cnt==0)
	  	{
		$rem = new Remember();
		$rem -> setClassName('Folder');
		$rem -> setItemId($folder->getId());
		$rem->setSessionId(session_id());
		$rem->save();
	  	}
	  	
	  	if($folder->hasParent())
	  	{
	  		
	  		$par = $folder->retrieveParent();
	  		foreach ($par as $p)
	  		{
	  		    	
	  			RememberPeer::RememberOpenFolder($p->getId());
	  		}
	  	}
	  	
		////
		
		
	}
	

	
	 public static function getArrayrec($folder, $arr)
	{
		return array('s','s');
		$arr[] = $folder->getId();
		if($folder->hasParent())
		{	
			RememberPeer::getArrayrec($folder->getParent(),$arr);
		}
		else 
		{
           // print_r ($arr);
		    //die;
			return $arr;
		}
	}
	
		public static function  db_getpath($folder)
		{
		      $dbm = new db_manipulations;
		      $dbm->db_get_path($folder);
		      return $dbm->get_result();
		}

	
	
  
	
}



class db_manipulations
{

    public $result;

    public function __construct()
    {
        $this->result = array();
    }

    public function set_table($inp)
    {
        $this->table = $inp;
    }

    public function get_result()
    {
        return $this->result;
    }

    public function db_get_path($folder)
    {
        $this->db_get_path_core($folder);
        $this->result = array_reverse($this->result);
        unset($this->result[0]);
    }

    public function db_get_path_core($folder)
    {
        $this->result[] = $folder->getId();
        if ($folder->hasParent())
            $this->db_get_path_core($folder->getParent());
    }

}

